﻿<%@ Page Language="C#" Inherits="TPG.SharePoint.Workflow.BulkTaskPage, TPG.SharePoint.Workflow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d3a33f5f62ef53ef" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormSection" Src="~/_controltemplates/InputFormSection.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormControl" Src="~/_controltemplates/InputFormControl.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ButtonSection" Src="~/_controltemplates/ButtonSection.ascx" %>
<%@ Register TagPrefix="wss" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Assembly Name="TPG.SharePoint.Workflow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d3a33f5f62ef53ef" %>
<%@ Import Namespace="TPG.SharePoint.Workflow" %>

<asp:Content ID="PageTitle" ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">
</asp:Content>

<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderId="PlaceHolderPageTitleInTitleArea" runat="server" >
</asp:Content>

<asp:Content ID="PageDescription" ContentPlaceHolderId="PlaceHolderPageDescription" runat="server">
</asp:Content>

<asp:Content ID="Main" ContentPlaceHolderId="PlaceHolderMain" runat="server">
<table class="ms-propertysheet" border="0" width="100%" cellspacing="0" cellpadding="0">
    <asp:Repeater ID="Tasks" runat="server">
        <ItemTemplate>
            <tr>
                <td>
                    <asp:HiddenField ID="Id" Value='<%# Eval("ListItemId") %>' runat="server" />
                    <%--your content here--%>
                </td>                
            </tr>
        </ItemTemplate>
    </asp:Repeater>
    <wssuc:ButtonSection runat="server" ShowStandardCancelButton="false">
        <template_buttons>
            <asp:Button id="SaveButton" UseSubmitBehavior="false" runat="server" CommandName="Commit" Text="Approve" />
            <asp:Button id="CancelButton" UseSubmitBehavior="false" runat="server" Text="Cancel" CommandName="Cancel" />
        </template_buttons>
    </wssuc:ButtonSection>
</table>
</asp:Content>

<script runat="server" type="text/C#">
    protected override void OnLoad(EventArgs e)
    {
        if(IsInitialLoad)
        {
            Tasks.DataSource = GetTaskItems();
            Tasks.DataBind();
        }
        base.OnLoad(e);
    }

    protected void OkButton_Click(object sender, EventArgs e)
    {
        TaskItemCollection results = new TaskItemCollection(TaskContentType);
        foreach (RepeaterItem item in Tasks.Items)
        {
            int id = Int32.Parse((item.FindControl("Id") as HiddenField).Value);
            TaskItem dataItem = results.NewTaskItem(id);
            // update data item
        }
        CommitTaskItems(results);
    }

    protected void CancelButton_Click(object sender, EventArgs e)
    {
        CancelTaskItems();
    }
        
</script>